package com.example.demo.controller;

/**
 * @ClassName TestRedisController
 * @Description TODO
 * Author yangqinglin
 * @Date 2021/1/28 14:53
 * @Version
 **/
import com.example.demo.utils.redistets.Test01;
import org.springframework.beans.factory.annotation.Autowired;
  import org.springframework.data.redis.core.RedisTemplate;
  import org.springframework.stereotype.Controller;
  import org.springframework.web.bind.annotation.RequestMapping;
  import org.springframework.web.bind.annotation.RequestMethod;
  import org.springframework.web.bind.annotation.ResponseBody;

          import javax.servlet.http.HttpServletRequest;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.concurrent.TimeUnit;

         /**
 15  * @author
 16  * @description TODO
 17  * @create
 18  */
         @Controller
 @RequestMapping("/test")
 public class TestRedisController {


     @Autowired
     private RedisTemplate<String,Object> redisTemplate;
     @RequestMapping("/testqj")
     public void testQJAttend(){

             }


             @RequestMapping("/demo")
     @ResponseBody
     public String[] demo(HttpServletRequest request){
                 List<Test01> userList = new ArrayList<Test01>();

                 Test01 user1 = new Test01();
                 user1.setUserName("风雅颂");
                 user1.setPassword("aw916132444");
                 user1.setPhoneNum("13874877512");

                 Test01 user2 = new Test01();
                 user2.setUserName("水雷屯");
                 user2.setPassword("xf82652215");
                 user2.setPhoneNum("15576758485");

                 Test01 user3 = new Test01();
                 user3.setUserName("天山遁");
                 user3.setPassword("sd555292222");
                 user3.setPhoneNum("13515114556");

                 userList.add(user1);
                 userList.add(user2);
                 userList.add(user3);
                 redisTemplate.opsForValue().set("userList",userList,60, TimeUnit.SECONDS);
                 redisTemplate.opsForValue().set("123","ahhahahah");
                 return null;
             }

             @RequestMapping(value="getValue",method={RequestMethod.GET,RequestMethod.POST})
     @ResponseBody
     public Object getValue(){
                 Object object = redisTemplate.opsForValue().get("123");
                 return object;
             }


         }
